/**
 * Company : Thai Informatic System Co., Ltd.
 * Created By : Dr.Tree
 * Created On : Jul 14, 2012  7:13:46 PM 
 * e-Mail : chatree@tis.co.th
 * Mobile Phone : (+66) 087-921-5115
 * Package Name : jpa.service.promis.construction
 * File Name : VwSyncRequestPaymentHRiseServices.java
 * TODO
 */
package jpa.service.promis.construction;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.persistence.EntityManager;
import org.apache.log4j.Logger;

import promis.utility.CommonService;

import jpa.entitys.promis.construction.VwSyncRequestPayment;
import jpa.entitys.promis.construction.VwSyncRequestPaymentHRise;
import jpa.service.common.JPAService;

/**
 * @author chatree
 *
 */
public class VwSyncRequestPaymentHRiseServices extends JPAService {
	
	private static final Logger log = Logger.getLogger(VwSyncRequestPaymentHRiseServices.class);

	/**
	 * @param em
	 */
	public VwSyncRequestPaymentHRiseServices(EntityManager em) {
		super(em);
	}
	

	public VwSyncRequestPaymentHRise findById(String id) throws Exception {		
	
		return super.ConvertToYoureObject(super.find(id, "VwSyncRequestPaymentHRise.findById"));				
	}
	
	public List<VwSyncRequestPaymentHRise> findAll() throws Exception {
		return super.ConvertToYoureObject(super.findAll("VwSyncRequestPaymentHRise.findAll"));
	}
	
	public List<VwSyncRequestPaymentHRise> findByDocumentNo(String company, String project ,String requestNo, String status, String syncIsstaging) throws Exception {
		Map<String,Object> mapWhereValue = new HashMap<String, Object>();				
		mapWhereValue.put("company", company);
		mapWhereValue.put("project", project);
		mapWhereValue.put("requestNo", requestNo);
		mapWhereValue.put("status", status);
		
		if(!CommonService.IsNull(syncIsstaging)){
			mapWhereValue.put("syncIsstaging", syncIsstaging);
			return super.ConvertToYoureObject(super.find("VwSyncRequestPaymentHRise.findByDocumentNo1", mapWhereValue));
		}			
		else
			return super.ConvertToYoureObject(super.find("VwSyncRequestPaymentHRise.findByDocumentNo", mapWhereValue));
	}

	public List<VwSyncRequestPaymentHRise> findByDocumentWithoutVO(String company, String project ,String documentNo, String refType, String status, String syncIsstaging) throws Exception {
		Map<String,Object> mapWhereValue = new HashMap<String, Object>();				
		mapWhereValue.put("company", company);						
		mapWhereValue.put("project", project);						
		mapWhereValue.put("documentNo", documentNo);				
		mapWhereValue.put("status", status);						
		mapWhereValue.put("refType", refType);						
		mapWhereValue.put("syncIsstaging", syncIsstaging);			
		
		return super.ConvertToYoureObject(super.find("VwSyncRequestPaymentHRise.findByDocumentWithoutVO", mapWhereValue));
	}
	
	public List<VwSyncRequestPaymentHRise> findByDocumentWithVO(String company, String project ,String documentNo, String status, String syncIsstaging) throws Exception {
		Map<String,Object> mapWhereValue = new HashMap<String, Object>();				
		mapWhereValue.put("company", company);						
		mapWhereValue.put("project", project);						
		mapWhereValue.put("documentNo", documentNo);				
		mapWhereValue.put("status", status);						
		mapWhereValue.put("syncIsstaging", syncIsstaging);			
		
		return super.ConvertToYoureObject(super.find("VwSyncRequestPaymentHRise.findByDocumentWithVO", mapWhereValue));
	}
	
	public List<VwSyncRequestPaymentHRise> findByDocUnit(String company, String project, String buildingPhase, String zoneCode, String unitNumber ,String documentNo, String status) throws Exception {
		Map<String,Object> mapWhereValue = new HashMap<String, Object>();				
		mapWhereValue.put("company", company);
		mapWhereValue.put("project", project);
		mapWhereValue.put("buildingPhase", buildingPhase);
		mapWhereValue.put("zoneCode", zoneCode);
		mapWhereValue.put("unitNumber", unitNumber);
		mapWhereValue.put("documentNo", documentNo);
		mapWhereValue.put("status", status);
		
		return super.ConvertToYoureObject(super.find("VwSyncRequestPaymentHRise.findByDocUnit", mapWhereValue));
	}

}
